"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
var app = getApp();
exports.default = Page({
  data: {
    status: "0",
    header: [{
      id: 0,
      name: "全部"
    }, {
      id: 1,
      name: "一级团队"
    }, {
      id: 2,
      name: "二级团队"
    }]
  },
  onLoad: function onLoad(e) {
    var _this = this;
    var money = e.money;
    var openid = wx.getStorageSync("openid");
    /*wx.request({
      url: app.globalData.host,
      data: {
        mod: "do",
        act: "type",
        ssid: openid,
        mid: "type"
      },
      method: "post", // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function(res) {
        //console.log(res);
        _this.setData({
          header: res.data.info
        });
      },
      fail: function() {
        // fail
      },
      complete: function() {
        // complete
      }
    });*/
    wx.request({
      url: app.globalData.host,
      data: {
        mod: "record",
        act: "money",
        ssid: openid,
        type: ""
      },
      method: "post", // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function success(res) {
        // success
        console.log(res);
        _this.setData({
          openid: openid,
          money: money,
          statistics: res.data.tab,
          spreadList: res.data.info
        });
      }
    });
  },
  setStyle: function setStyle(e) {
    var _this = this;
    var type = e.currentTarget.dataset.type;
    wx.request({
      url: app.globalData.host,
      data: {
        mod: "record",
        act: "money",
        ssid: _this.data.openid,
        opt: type
      },
      method: "post", // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
      header: {
        "Content-Type": "application/x-www-form-urlencoded"
      },
      success: function success(res) {
        // success
        //console.log(res);
        _this.setData({
          status: type,
          statistics: res.data.tab,
          spreadList: res.data.info
        });
      }
    });
  },
  linkPay: function linkPay(e) {
    var mid = e.currentTarget.dataset.mid;
    var name = e.currentTarget.dataset.name;
    var money = e.currentTarget.dataset.money;
    var activity = e.currentTarget.dataset.activity;
    wx.navigateTo({
      url: "pay/pay?money=" + money + "&mid=" + mid + "&name=" + name + "&activity=" + activity,
      success: function success(res) {
        // success
      },
      fail: function fail() {
        // fail
      },
      complete: function complete() {
        // complete
      }
    });
  }
});